package ls.test;

import ls.dao.CourseTeacherDAO;
import ls.dao.DAOFactory;
import ls.dao.StudentDAO;
import ls.entity.CourseTeacher;
import ls.entity.Student;

import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        System.out.println("现在测试助教子系统，请选择您的身份：1.研究生 2.授课教师");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if(n == 1)
        {
            String student_id; // 从登录获取研究生学号
            System.out.println("请输入研究生学号：");
            Scanner scanner1 = new Scanner(System.in);
            student_id = scanner1.next();
            StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
            System.out.println("学号为"+student_id+"的研究生您好！");
            Student student = studentDAO.getStudent(student_id);
            if(student == null)
            {
                CreateStudent createStudent = new CreateStudent();
                createStudent.createStudent(student_id);// 新增研究生
            }
            else
            {
                ChooseCourse chooseCourse = new ChooseCourse();
                chooseCourse.chooseCourse(student_id);
            }
        }
        else if(n == 2)
        {
            CourseTeacherDAO courseTeacherDAO = DAOFactory.getInstance().getCourseTeacherDAO();
            String teacher_id;
            System.out.println("请输入授课教师工号：");
            teacher_id = scanner.next();
            CourseTeacher courseTeacher = courseTeacherDAO.getTeacher(teacher_id);
            if(courseTeacher == null)
            {
                System.out.println("您不是已录入的授课教师，若需录入请输入1，退出输入2");
                int c = scanner.nextInt();
                if(c == 1)
                {
                    System.out.println("请输入您的登录密码：");
                    String teacher_pwd = scanner.next();
                    System.out.println("请输入您的姓名：");
                    String teacher_name = scanner.next();
                    CourseTeacher ct = new CourseTeacher();
                    ct.setTeacher_id(teacher_id);
                    ct.setTeacher_name(teacher_name);
                    ct.setTeacher_pwd(teacher_pwd);
                    courseTeacherDAO.addCourseTeacher(ct);
                    System.out.println("添加授课教师成功！");
                }
                else return;
            }
            System.out.println("工号为"+teacher_id+"的教师您好！");
            System.out.println("请选择您要进行的操作：");
            System.out.println("1.课程信息录入");
            System.out.println("2.助教选择");
            System.out.println("3.审核助教工作评定表");
            System.out.println("4.查看已录入的我的全部课程");
            System.out.println("5.查看我已处理的全部评定表");
            System.out.println("6.退出系统");
            Scanner scanner2 = new Scanner(System.in);
            int choose = scanner2.nextInt();
            if(choose == 1)
            {
                CreateCourse createCourse = new CreateCourse();
                createCourse.create(teacher_id);
            }
            else if(choose == 2)
            {
                ChooseStudent cs = new ChooseStudent();
                cs.chooseStudent(teacher_id);
            }
            else if(choose == 3)
            {
                TeacherEvaluate te = new TeacherEvaluate();
                te.teacherEvaluate(teacher_id);
            }
            else if(choose == 4)
            {
                ChooseStudent chooseStudent = new ChooseStudent();
                chooseStudent.showCourse(teacher_id);
            }
            else if(choose == 5)
            {
                TeacherEvaluate te = new TeacherEvaluate();
                te.getMyEvaluate(teacher_id);
            }
            else if(choose == 6)
            {
                return;
            }
        }
    }
}
